package com.bupt.film.controller;



import com.bupt.annotation.LoginRequired;
import com.bupt.film.client.FilmInfoClient;
import com.bupt.film.entity.Film;
import com.bupt.film.entity.Hall;
import com.bupt.film.service.FilmInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;
import java.util.Map;

@RestController
public class FilmInfoController implements FilmInfoClient {

    @Autowired
    private FilmInfoService filmInfoService;

    @Override
    @LoginRequired
    public List<Hall> getHallsInfoList() {
//        throw new BusinessException(ResultCode.MISSING_IMPORTANT_PARAM);
        return filmInfoService.getHallsInfoList();
    }

    @Override
    public String getHallsInfo() {
        return filmInfoService.getHallsInfo();
    }

    @Override
    public Hall getOneHallInfo(String hallId) {
        return filmInfoService.getOneHallInfo(hallId);
    }

    @Override
    public List<Film> getFilmsInfo() {
        return filmInfoService.getFilmsInfo();
    }

    @Override
    public Film getOneFilmInfo(String filmId) {
        return filmInfoService.getOneFilmInfo(filmId);
    }

    @Override
    public List<Film> getFilmsWithinTimeRange(String hallId, Date startTime, Date endTime) {
        return filmInfoService.getFilmsWithinTimeRange(hallId, startTime, endTime);
    }


    //https://blog.csdn.net/coder1998/article/details/106450905/
    //前台传递日期可能会出错，解决链接
    @Override
    public Map<String, Object> getFilmShowDetail(String hallId, String filmId, Date showDate) {
        return filmInfoService.getFilmShowDetail(hallId, filmId, showDate);
    }
}
